import {Component, OnInit, AfterViewInit, OnDestroy} from '@angular/core';
import {TipsService} from './tips.service';

@Component({
    selector: 'kylin-tips',
    templateUrl: './tips.component.html',
    styleUrls: ['./tips.component.less']
})
export class TipsComponent implements OnInit, AfterViewInit, OnDestroy {

    arr = [1, 2, 3, 4, 5];
    currentArrIndex = -1;
    interval: any;

    constructor(private tipsService: TipsService
    ) {

    }

    ngOnInit() {
        this.startChange();
        this.tipsService.fetchUserData();
    }

    ngAfterViewInit() {

    }

    ngOnDestroy() {

    }

    changeCurrentArrIndex() {
        this.currentArrIndex = (this.currentArrIndex + 1) % this.arr.length;
        console.log(this.currentArrIndex);
    }

    startChange() {
        this.interval = setInterval(() => {
            this.changeCurrentArrIndex();
        }, 1500);
    }
}
